/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ua.i.kotionokyurievna.jewelry.domain.supply;

import java.util.Date;
import ua.i.kotionokyurievna.jewelry.domain.employee.Employee;
import ua.i.kotionokyurievna.jewelry.domain.material.Material;

/**
 *
 * @author Kateryna_Reznik
 */
public class Supply {
    private int suppId;
    private Material material;
    private double price;
    private int quantity;
    private Employee acceptedBy;
    private Date date;

    public Supply() {
    }

    public Supply(Material material, double price, int quantity, Employee acceptedBy, Date date) {
        this.material = material;
        setPrice(price);
        this.quantity = quantity;
        this.acceptedBy = acceptedBy;
        this.date = date;
    }

    public Supply(int suppId, Material material, double price, int quantity, Employee acceptedBy, Date date) {
        this.suppId = suppId;
        this.material = material;
        setPrice(price);
        this.quantity = quantity;
        this.acceptedBy = acceptedBy;
        this.date = date;
    }
    
    public Supply ( Supply supply ){
        if ( supply != null ){
            this.suppId = supply.suppId;
            this.acceptedBy = supply.acceptedBy;
            this.date = supply.date;
            this.material = supply.material;
            setPrice(supply.price);
            this.quantity = supply.quantity;
        }
    }

    public int getSuppId() {
        return suppId;
    }

    public Material getMaterial() {
        return material;
    }

    public void setMaterial(Material material) {
        this.material = material;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        if ( price > 0){
            this.price = price;
        }
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public Employee getAcceptedBy() {
        return acceptedBy;
    }

    public void setAcceptedBy(Employee acceptedBy) {
        this.acceptedBy = acceptedBy;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @Override
    public String toString() {
        return "Supply{" + "suppId=" + suppId + ", material=" + material + 
                ", price=" + price + ", quantity=" + quantity + 
                ", acceptedBy=" + acceptedBy + ", date=" + date + '}';
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 17 * hash + (this.material != null ? this.material.hashCode() : 0);
        hash = 17 * hash + (int) (Double.doubleToLongBits(this.price) ^ 
                (Double.doubleToLongBits(this.price) >>> 32));
        hash = 17 * hash + this.quantity;
        hash = 17 * hash + (this.acceptedBy != null ? this.acceptedBy.hashCode() : 0);
        hash = 17 * hash + (this.date != null ? this.date.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Supply other = (Supply) obj;
        if (this.material != other.material && (this.material == null || 
                !this.material.equals(other.material))) {
            return false;
        }
        if (Double.doubleToLongBits(this.price) != Double.doubleToLongBits(other.price)) {
            return false;
        }
        if (this.quantity != other.quantity) {
            return false;
        }
        if (this.acceptedBy != other.acceptedBy && (this.acceptedBy == null || 
                !this.acceptedBy.equals(other.acceptedBy))) {
            return false;
        }
        if (this.date != other.date && (this.date == null || 
                !this.date.equals(other.date))) {
            return false;
        }
        return true;
    }
   
}
